package com.spingweb.controller.rest;

import com.spingweb.dto.Book;
import com.spingweb.service.BookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Controller,RequestMapping是两个很典型的框架
 * DispatchServlet，这些都是耳熟能详的类。
 * 使用swagger使其能够更直观的看出
 */
@RestController
@RequestMapping("/book")
public class BookControllerTest {


    @Autowired
    BookService bookService;

    @GetMapping("/add")
    public String hello(@RequestBody Book book) {
        bookService.add(book);
        return "add book success";
    }

    @RequestMapping("/bookList")
    public List<Book> bookList(@RequestBody Book book) {
        return bookService.query(book);
    }
}
